using System;

using Jeffrey.XFramework.XCrawl;

namespace Jeffrey.XFramework.XInteract
{
    public class MessagePackage
    {
        public MessagePackage(Int32 ThreadNum)
        {
            m_ThreadNum = ThreadNum;
        }

        protected MessagePackage() { }

        public Int32 ThreadNum { get { return m_ThreadNum; } }

        protected Int32 m_ThreadNum;
    }

    public class SpiderStatusPackage : MessagePackage
    {
        public SpiderStatusPackage(Int32 threadNum, CrawlSpider.SpiderStatus status)
            : this(threadNum, String.Empty, String.Empty, String.Empty, status)
        { }
        public SpiderStatusPackage(Int32 threadNum, String processor, CrawlSpider.SpiderStatus status)
            : this(threadNum, String.Empty, processor, String.Empty, status)
        { }
        public SpiderStatusPackage(Int32 threadNum, String uri, String depth, CrawlSpider.SpiderStatus status)
            : this(threadNum, uri, String.Empty, depth, status)
        { }
        protected SpiderStatusPackage(Int32 threadNum, String uri, String processor, String depth, CrawlSpider.SpiderStatus status)
            : base(threadNum)
        {
            m_Uri       = uri;
            m_Processor = processor;
            m_Depth     = depth;
            m_Status    = status;
        }
        
        public String Uri { get { return m_Uri; } }
        public String ProcessorName { get { return m_Processor; } }
        public CrawlSpider.SpiderStatus Status { get { return m_Status; } }
        public String Depth { get { return m_Depth; } }

        //for UriStatus...
        private String m_Uri;
        private String m_Processor;
        private CrawlSpider.SpiderStatus m_Status;
        private String m_Depth;
    }

    public class DownLoadingPackage : MessagePackage
    {
        public DownLoadingPackage(Int32 threadNum, Int32 bytes, Int32 total)
            : base(threadNum)
        {
            m_Bytes = bytes;
            m_Total = total;
        }

        public Int32 Bytes { get { return m_Bytes; } }
        public Int32 Total { get { return m_Total; } }

        //for DownLoading...

        private Int32 m_Bytes;
        /*
         * Notice: m_Total == 0  means the length is unavailable...
         *         m_Total == -1 means the message body is chunked...
         */
        private Int32 m_Total;
    }

    public class ErrorPackage : MessagePackage
    {
        public ErrorPackage(String uri, String error, String detail)
        {
            DateTime now = DateTime.Now;

            m_Date   = now.ToString();
            m_Error  = error;
            m_Detail = detail.Trim('\r', '\n', ' ');
            m_Uri    = uri;
        }
        public ErrorPackage(String uri, String error)
            : this(uri, error, String.Empty)
        { }

        public String Uri    { get { return m_Uri; } }
        public String Date   { get { return m_Date; } }
        public String Error  { get { return m_Error; } }
        public String Detail { get { return m_Detail; } }

        //for Errors...
        private String m_Uri;
        private String m_Date;
        private String m_Error;
        private String m_Detail;
    }
}


        



        
        

       